﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Moq;

namespace MoqContrib.AutoMock.Tests.TheMockHeap
{
    [TestFixture]
    class WhenUsingAKey
    {

        #region Types used for testing
        public interface IService { }
        public class Service : IService { }
        #endregion

        [Test]
        public void I_can_remember_mocks_by_their_keys()
        {
            var h = new MockHeap();
            var mock = new Mock<IService>();
            h[typeof(IService), "mock"] = mock;
            Assert.That(h[typeof(IService), "mock"], Is.SameAs(mock));
        }

        [Test]
        public void I_can_have_two_mocks_with_different_keys()
        {
            var h = new MockHeap();
            var mock1 = new Mock<IService>();
            var mock2 = new Mock<IService>();
            h[typeof(IService), "mock1"] = mock1;
            h[typeof(IService), "mock2"] = mock2;
            Assert.That(h[typeof(IService), "mock1"], Is.SameAs(mock1));
            Assert.That(h[typeof(IService), "mock2"], Is.SameAs(mock2));
        }

    }
}
